// src/hooks/usePermission.ts
import { ref } from 'vue'
import { useUserStore } from '@/stores/user'

export function usePermission() {
    const userStore = useUserStore()

    // 简易权限验证逻辑
    const hasPermission = (permission?: string | string[]) => {
        if (!permission) return true

        const userPermissions = userStore.permissions || []

        if (Array.isArray(permission)) {
            return permission.some(p => userPermissions.includes(p))
        }
        return userPermissions.includes(permission)
    }

    return {
        hasPermission
    }
}